home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / Thread Manager Extension 2.0.1 / Compiler Stuff / Interfaces / AIncludes / Threads.a
Encoding:
Text File  |  1994-06-03  |  7.2 KB  |  234 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Threads.a
  3. ;
  4. ;    Contains:    Assembly language interface to the Thread Manager
  5. ;
  6. ;    Copyright:    © 1990-1994 by Apple Computer, Inc., all rights reserved.
  7. ;
  8.  
  9. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  10.     IF &TYPE('__IncludingThreads__') = 'UNDEFINED' THEN
  11. __IncludingThreads__    SET    1
  12.  
  13. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  14.     IF &TYPE('__INCLUDINGTRAPS__') = 'UNDEFINED' THEN
  15.                     INCLUDE 'Traps.a'
  16.     ENDIF
  17. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  18.     IF &TYPE('_ThreadDispatch') = 'UNDEFINED' THEN
  19. _ThreadDispatch        OPWORD        $ABF2
  20.     ENDIF
  21. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  22. gestaltThreadMgrAttr            EQU        'thds'                ;Thread Manager attributes
  23. gestaltThreadMgrPresent         EQU         0                    ; bit true if Thread Mgr is present
  24. gestaltSpecificMatchSupport     EQU         1                    ; bit true if Thread Mgr supports exact match creation option
  25. gestaltThreadsLibraryPresent     EQU         2                    ; bit true if ThreadsLibrary (Native version) has been loaded
  26.  
  27. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  28. ; Thread states
  29. kReadyThreadState                EQU    0
  30. kStoppedThreadState                EQU    1
  31. kRunningThreadState                EQU    2
  32.  
  33. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  34. ; Thread characteristics (bit numbers in ThreadStyle)
  35. kCooperativeThread                EQU    0
  36. kPreemptiveThread                EQU    1
  37.  
  38. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  39. ; Thread identifiers
  40.         MACRO
  41.         ThreadID
  42.         DS.L    1
  43.         ENDM
  44. kNoThreadID                        EQU    0
  45. kCurrentThreadID                EQU    1
  46. kApplicationThreadID            EQU    2
  47.  
  48. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  49. ; Options when creating a thread (bit numbers in ThreadOptions)
  50. kNewSuspend                        EQU    0
  51. kUsePremadeThread                EQU    1
  52. kCreateIfNeeded                    EQU    2
  53. kFPUNotNeeded                    EQU 3
  54. kExactMatchThread                EQU 4
  55.  
  56. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  57. ; Information supplied to the custom scheduler
  58. SchedulerInfoRec                RECORD    0
  59. InfoRecSize                        DS.L    1
  60. CurrentThreadID                    ThreadID
  61. SuggestedThreadID                ThreadID
  62. InterruptedSyncThreadID            ThreadID
  63. Size                            EQU        *
  64.                                 ENDR
  65.  
  66. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  67. ; Define the selectors for the Thread Manager
  68. selectCreateThreadPool            EQU    1
  69. selectGetFreeThreadCount        EQU    2
  70. selectNewThread                    EQU    3
  71. selectDisposeThread                EQU    4
  72. selectYieldToThread                EQU    5
  73. selectGetCurrentThread            EQU    6
  74. selectGetThreadState            EQU    7
  75. selectSetThreadState            EQU 8
  76. selectSetThreadScheduler        EQU    9
  77. selectSetThreadSwitcher            EQU    10
  78. selectThreadBeginCritical        EQU    11
  79. selectThreadEndCritical            EQU    12
  80. selectSetDebuggerNotificationProcs    EQU    13
  81. selectGetThreadCurrentTaskRef        EQU    14
  82. selectGetThreadStateGivenTaskRef    EQU    15
  83. selectSetThreadReadyGivenTaskRef    EQU    16
  84. selectSetThreadTerminator        EQU    17
  85. selectSetThreadStateEndCritical        EQU    18
  86. selectGetDefaultThreadStackSize        EQU    19
  87. selectThreadCurrentStackSpace        EQU    20
  88. selectGetSpecificFreeThreadCount    EQU    21
  89.  
  90. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  91. ; Define the parameter size passed for each call
  92. paramWordsCreateThreads            EQU    5
  93. paramWordsGetFreeThreadCount    EQU    4
  94. paramWordsNewThread                EQU    14
  95. paramWordsDisposeThread            EQU    5
  96. paramWordsYieldToThread            EQU    2
  97. paramWordsGetCurrentThread        EQU    2
  98. paramWordsGetThreadState        EQU    4
  99. paramWordsSetThreadState        EQU    5
  100. paramWordsSetThreadScheduler    EQU    2
  101. paramWordsSetThreadSwitcher        EQU    7
  102. paramWordsThreadBeginCritical    EQU    0
  103. paramWordsThreadEndCritical        EQU    0
  104. paramWordsSetDebuggerNotificationProcs    EQU    6
  105. paramWordsGetThreadCurrentTaskRef        EQU    2
  106. paramWordsGetThreadStateGivenTaskRef    EQU    6
  107. paramWordsSetThreadReadyGivenTaskRef    EQU    4
  108. paramWordsSetThreadTerminator    EQU    6
  109. paramWordsSetThreadStateEndCritical        EQU    5
  110. paramWordsGetDefaultThreadStackSize        EQU    4
  111. paramWordsThreadCurrentStackSpace        EQU    4
  112. paramWordsGetSpecificFreeThreadCount    EQU    6
  113.  
  114. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  115. ; Errors *** put actual number in SysErr.a
  116. threadTooManyReqsErr            EQU        -617
  117. threadNotFoundErr                EQU        -618                    ; no thread with specified identifier
  118. threadProtocolErr                EQU        -619
  119.  
  120. ;————————————————————————————————————————————————————————————————————————————————————————————————————
  121. ; Thread Manager routines
  122.         MACRO
  123.         _CreateThreads
  124.         DoDispatch _ThreadDispatch,selectCreateThreads,paramWordsCreateThreads
  125.         ENDM
  126.  
  127.         MACRO
  128.         _GetFreeThreadCount
  129.         DoDispatch _ThreadDispatch,selectGetFreeThreadCount,paramWordsGetFreeThreadCount
  130.         ENDM
  131.  
  132.         MACRO
  133.         _GetSpecificFreeThreadCount
  134.         DoDispatch _ThreadDispatch,selectGetSpecificFreeThreadCount,paramWordsGetSpecificFreeThreadCount
  135.         ENDM
  136.         
  137.         MACRO
  138.         _GetDefaultThreadStackSize
  139.         DoDispatch _ThreadDispatch,selectGetDefaultThreadStackSize,paramWordsGetDefaultThreadStackSize
  140.         ENDM
  141.  
  142.         MACRO
  143.         _ThreadCurrentStackSpace
  144.         DoDispatch _ThreadDispatch,selectThreadCurrentStackSpace,paramWordsThreadCurrentStackSpace
  145.         ENDM
  146.  
  147.         MACRO
  148.         _NewThread
  149.         DoDispatch _ThreadDispatch,selectNewThread,paramWordsNewThread
  150.         ENDM
  151.  
  152.         MACRO
  153.         _DisposeThread
  154.         DoDispatch _ThreadDispatch,selectDisposeThread,paramWordsDisposeThread
  155.         ENDM
  156.  
  157.         MACRO
  158.         _YieldToThread
  159.         DoDispatch _ThreadDispatch,selectYieldToThread,paramWordsYieldToThread
  160.         ENDM
  161.  
  162.         MACRO
  163.         _YieldToAnyThread
  164.         clr.l    -(sp)
  165.         _YieldToThread
  166.         ENDM
  167.  
  168.         MACRO
  169.         _GetCurrentThread
  170.         DoDispatch _ThreadDispatch,selectGetCurrentThread,paramWordsGetCurrentThread
  171.         ENDM
  172.  
  173.         MACRO
  174.         _GetThreadState
  175.         DoDispatch _ThreadDispatch,selectGetThreadState,paramWordsGetThreadState
  176.         ENDM
  177.  
  178.         MACRO
  179.         _SetThreadState
  180.         DoDispatch _ThreadDispatch,selectSetThreadState,paramWordsSetThreadState
  181.         ENDM
  182.  
  183.         MACRO
  184.         _SetThreadStateEndCritical
  185.         DoDispatch _ThreadDispatch,selectSetThreadStateEndCritical,paramWordsSetThreadStateEndCritical
  186.         ENDM
  187.  
  188.         MACRO
  189.         _SetThreadScheduler
  190.         DoDispatch _ThreadDispatch,selectSetThreadScheduler,paramWordsSetThreadScheduler
  191.         ENDM
  192.  
  193.         MACRO
  194.         _SetThreadSwitcher
  195.         DoDispatch _ThreadDispatch,selectSetThreadSwitcher,paramWordsSetThreadSwitcher
  196.         ENDM
  197.  
  198.         MACRO
  199.         _SetThreadTerminator
  200.         DoDispatch _ThreadDispatch,selectSetThreadTerminator,paramWordsSetThreadTerminator
  201.         ENDM
  202.  
  203.         MACRO
  204.         _ThreadBeginCritical
  205.         DoDispatch _ThreadDispatch,selectThreadBeginCritical,paramWordsThreadBeginCritical
  206.         ENDM
  207.  
  208.         MACRO
  209.         _ThreadEndCritical
  210.         DoDispatch _ThreadDispatch,selectThreadEndCritical,paramWordsThreadEndCritical
  211.         ENDM
  212.  
  213.         MACRO
  214.         _SetDebuggerNotificationProcs
  215.         DoDispatch _ThreadDispatch,selectSetDebuggerNotificationProcs,paramWordsSetDebuggerNotificationProcs
  216.         ENDM
  217.  
  218.         MACRO
  219.         _GetThreadCurrentTaskRef
  220.         DoDispatch _ThreadDispatch,selectGetThreadCurrentTaskRef,paramWordsGetThreadCurrentTaskRef
  221.         ENDM
  222.  
  223.         MACRO
  224.         _GetThreadStateGivenTaskRef
  225.         DoDispatch _ThreadDispatch,selectGetThreadStateGivenTaskRef,paramWordsGetThreadStateGivenTaskRef
  226.         ENDM
  227.  
  228.         MACRO
  229.         _SetThreadReadyGivenTaskRef
  230.         DoDispatch _ThreadDispatch,selectSetThreadReadyGivenTaskRef,paramWordsSetThreadReadyGivenTaskRef
  231.         ENDM
  232.  
  233.         ENDIF            ; Already included
  234.